home *** CD-ROM | disk | FTP | other *** search
- /*
- * GIF.h Header file for GIF translation
- * Basic data structures defining the file format
- *
- * GIF stands for "Graphics Interchange Format" and is a trademark of CompuServe.
- * an H&R Block Company
- *
- */
-
- #define NIL (0L)
- #define TRUE true
- #define FALSE false
-
- /* PROTOTYPE(s) */
- Boolean ProcessGIF(Str255 filename, short vRefnum);
-
-
-
- unsigned char signature[6];
-
- typedef unsigned char UBYTE;
- typedef unsigned short USHORT;
-
- /* The logical screen width and height can both be larger than the physical display.
- How images larger than the physical display are handled is implementation
- dependent and can take advantage of such things as scrolling windows or may
- be clipped to the edges of the display.
-
- The value of "pixel" also defines the maximum number of colors within an image.
- The range of values is 0..7 (1..8 bits). This gives a range of 2 (B&W) to
- 256 colors. Bit 3 of the flags byte is reserved for future use and MUST be zero.
-
- The clrFlags field is interpreted as follows:
- Boolean hasColorMap
- 0..3 colorResolutionMinus1
- 0..1 mustBeZero
- 0..7 pixelsMinus1
- */
-
- typedef struct {
- USHORT rastWidth; /* LSB, MSB on disk of raster width in pixels */
- USHORT rastHeightLo; /* LSB, MSB on disk of raster height in pixels */
- UBYTE clrFlags; /* See above for interpretation */
- UBYTE background; /* Color index of screen background (comes from Global color map, or default map if no global defined) */
- UBYTE terminator; /* This should be zero */
- } ScreenDescriptor;
-
- /* The Global Color Map is optional and its presence is indicated by a "TRUE" value
- for the hasColorMap bit of the clrFlags field, above. There will be a sequence
- of 2**(bitsPerPixel) RGBType entries.
- ie either 2, 4, 8, 16, 32, 64, 128, 256 -- actually, only 2, 4, 16, and 256
- are common.
-
- Each image pixel will be displayed according to its closest match with an
- available color of the display based upon this color map. The color components
- represent a fractional intensity value from none (0) to full (255) -- white
- is {255, 255, 255} and black is {0, 0, 0}. This is mapped on the Macintosh
- into the two-byte RGB values used in ColorQD via the expedient of ORing the
- intensity with the 8-bit shift of itself, ie 128 maps to 0x8080.
- */
-
- typedef struct {
- UBYTE red;
- UBYTE green;
- UBYTE blue;
- } RGBType;
-
- /* The ImageDescriptor defines the actual placement and extents of the following
- image within the space defined by the ScreenDescriptor. Also defined are flags
- to indicate the presence of a local color lookup map, and to define the pixel
- display sequence. Each ImageDescriptor is introduced by an image separator
- character. The role of this separator is to provide a synchronization character
- to introduce an ImageDescriptor. This is desirable if there is more than one
- image in a GIF file. This character is defined as 0x2c (ascii comma). When
- this character is encountered between images, it will be immediately followed
- by an ImageDescriptor.
-
- Any bytes encountered between the end of an image and the image separator
- character are to be ignored.
-
- The specifications for the image position and size must be confined to the
- dimensions defined by the ScreenDescriptor. OTHO, it is not necessary that the
- image fill the entire display area provided.
- */
-
- typedef struct {
- UBYTE imageSeparator; /* Must be 0x2c - a comma */
- USHORT leftInset; /* LSB, MSB on disk of the inset from the left for the first pixel */
- USHORT vertInset; /* LSB, MSB on disk of the inset from the top for the first pixel */
- USHORT imageWidth; /* LSB, MSB on disk of the image width */
- USHORT imageHeight; /* LSB, MSB on disk of the image height */
- UBYTE imageFlags; /* See following masks on imageFlags */
- } ImageDescriptor;
-
- /* A more structured definition would be:
- (useGlobalColorMap, useLocalColorMap)
- (formattedSequential, formattedInterlaced)
- 0..7 reserved
- 0..7 numPixelsMinus1
- */
- #define colorMapMask 0x80
- #define interlaceMask 0x40
- #define reservedMask 0x38
- #define pixelMask 0x07
-
- #define IMAGESEPARATOR 0x2c
- #define PALENTSIZE 10 /* 8 bits plus 1 pixel border on all sides */
- #define BEHIND (WindowPtr) (-1L)
- #define MAXSHORT 0x7FFF